package 第十二章多态;

public class 多态测试02 {
    public static void main(String[] args) {

        //父类型引用指向子类型
        //向上转型
        Animal a1 = new cat();
        Animal a2 = new bird();

        //向下转型
        if (a1 instanceof cat) {
            cat c1 = (cat) a1;
            c1.catchmouse();
        }
        if (a2 instanceof bird) {
            bird b1 = (bird) a2;
            b1.fly();
        }
    }


}